﻿using FarmSmartSleep.Common.Dtos;
using FarmSmartSleep.Organ.API.Application.Descendantsafter;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace FarmSmartSleep.Organ.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DescendantsafteController : ControllerBase
    {
        /// <summary>
        /// 获取后裔转种
        /// </summary>
        public readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public DescendantsafteController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 批量添加后裔转种信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> Handle(DescendantsafterCommand request)
        {
            return await this.mediator.Send(request);
        }

        /// <summary>
        /// 后裔转种记录查询        
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception> 
        [HttpPost]
        public async Task<Result> Handle1(DescendantsafterSelectCommand request)
        {
            return await this.mediator.Send(request);
        }
    }
}
